﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_MembershipProvider_Access_Controls_alphalinks : System.Web.UI.UserControl
{
    string[] letters = { "All", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
					"L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
					"W", "X", "Y", "Z"};

    private string selectedLetter;
    private int selectedIndex;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["selectedLetter"] == null)
        {
            selectedLetter = "All";
            ViewState["selectedLetter"] = "All";
        }
    }
    public void Page_PreRender()
    {
        /*
         * I moved this out of the Page_Load so that I could disable the selected link.
         * Prior to moving it out of Page_Load, the deselected link lagged one behind, because
         * Page_Load fires prior to the command event handler.
         */
        __theAlphalink.DataSource = letters;
        __theAlphalink.DataBind();
    }
    public string Letter
    {
        get
        {
            return ViewState["selectedLetter"].ToString();
        }
        set
        {
            ViewState["selectedLetter"] = value;
        }
    }

    private void Select(object sender, CommandEventArgs e)
    {
    }

    protected void DisableSelectedLink(object sender, RepeaterItemEventArgs e)
    {
        LinkButton lb = (LinkButton)e.Item.Controls[1];
        if (lb.Text == Letter)
            lb.Enabled = false;
    }

    protected void link_Command(object sender, CommandEventArgs e)
    {
        selectedLetter = e.CommandArgument.ToString();
        ViewState["selectedLetter"] = e.CommandArgument.ToString();

    }
}
